/* eslint-disable */
import React, { Component } from 'react';
import moment from 'moment';

class Timer extends Component{

  state = {
    time : "",
  }

  timer = null;

  componentDidMount() {
    this.poll();
  }

  componentWillUnmount() {
    clearTimeout(this.timer);
  }

  poll = () => {
    this.setState({
      time : moment().format("YYYY-MM-DD HH:mm:ss")
    })
    this.timer = setTimeout(() => {
      this.poll();
    }, 1000)
  }

  render() {
    return (
      <div 
        style={{
          color: '#fff',
          fontFamily: '黑体',
          fontSize: 14,
          letterSpacing: 2
        }}
      >
        { this.state.time }
      </div>
    )
  }

}

export default Timer